﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace 医院药库管理系统
{
    public partial class 管理员登录 : Form
    {
        public 管理员登录()
        {
            InitializeComponent();
        }

        private void bt_dl_Click(object sender, EventArgs e)
        {
            if (tb_yhm.Text.Trim() == "" || tb_password.Text.Trim() == "")
            {
                MessageBox.Show("用户名或密码不能为空！");
                tb_yhm.Focus();
                return;
            }
            string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            string sqlStr = string.Format("select count(*) from [tb_Administrator] where Name='{0}' and Password='{1}'", tb_yhm.Text.Trim(), tb_password.Text.Trim());
            using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand(sqlStr, conn);
                conn.Open();
                int n = Convert.ToInt32(cmd.ExecuteScalar());
                if (n == 1)
                {
                    首页 f2 = new 首页();
                    f2.Name = tb_yhm.Text.ToString();
                    f2.Show();
                    管理员登录 f = new 管理员登录();
                    f.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误，请重新输入！");
                    tb_yhm.Text = "";
                    tb_password.Text = "";
                    tb_yhm.Focus();
                }

            }
        }

        private void bt_zc_Click(object sender, EventArgs e)
        {

            管理员注册 f1 = new 管理员注册();
            f1.Show();
        }
    }
}
